#pragma once
#include "PlayerColor.h"
#include "FieldResource.h"
#include "DieNumber.h"

namespace catan
{
	struct GamePlayState
	{
		enum Enum
		{
			PrebuildingFirst,
			PrebuildingSecond,
			GamePlaying,
			GameFinish,
		};
	};
	class BoardItems;

	class Board : public BoardItem
	{
	public:
		friend class boost::archive::save_access;
		Board(void);
		virtual ~Board(void);
		bool IsPrebuilding()
		{
			return mGamePlayState <= GamePlayState::PrebuildingSecond;
		}

		bool IsPrebuildingFirst()
		{
			return mGamePlayState == GamePlayState::PrebuildingFirst;
		}

		void RemapHandle();
		template<class HandleType>
		Handle<HandleType> GetHandle(HandleId id)
		{
			Handle<HandleType> ret(id, mBoardItems->Get<HandleType>(id));
			VALID(ret);
			return ret;
		}

	public: //members

		virtual void Remap(BoardItems* boardItems);

		Fields mFields;
		BuildPoints mBuildPoints;
		Ports mPorts;
		DevelopmentCards mDevelopmentCards;
		FieldResources mFieldResources;
		FieldDieNums mFieldDieNums;
		Handle<Robber> mRobber;
		
		Players mPlayers;
		Edges mEdges;
		DieNumbers mDieNumbers;
		ResourceCards mResourceCards[FieldResourceType::Num];
		bool mDied;
		int mCurrPlayerNum;

		GamePlayState::Enum mGamePlayState;

		BoardItems* mBoardItems;
		
		template<class Serializer>
		void serialize(Serializer & s, const unsigned int version)
		{
			s 
				& mBuildPoints 
				& mCurrPlayerNum 
				& mDevelopmentCards 
				& mDied 
				& mEdges 
				& mFieldDieNums 
				& mFieldResources 
				& mFields 
				& mGamePlayState 
				& mPlayers 
				& mPorts 
				& mResourceCards 
				& mRobber;
		}
	};

  	

}	

